<template>
    <!-- 用户头像 -->
    <span @click="enterUserIndex" v-if="userImg" class="head-img">
        <image-vant
        class="user-img" 
        :isRound="isRound" 
        :src="userImg" 
        :height="height"
        :width="width"
        ></image-vant>
    </span>
</template>

<script>
// 自定义组件
import ImageVant from "_components/project/common/ImageVant"

// 自定义方法
import { enterUserIndex } from '_projectFn/page'

export default {
    name: 'UserHeadImg',
    props: {
        userImg: {
            type: String,
            default: ''
        },
        isRound: {
            type: Boolean,
            default: true
        },
        height: {
            type: Number,
            default: 45
        },
        width: {
            type: Number,
            default: 45
        },
        userId: {
            default: ''
        },
        isEnterUserIndex: {
            type: Boolean,
            default: true
        },
    },
    methods: {
        enterUserIndex() {
            if (this.userId && this.isEnterUserIndex) {
                // if (process.env.IS_LOCAL) {
                //     console.log('未开发个人主页页面')
                // } else {
                //     window.location.href = `../user-index.html?type=normal&userId=${this.userId}`
                // }
                enterUserIndex({
                    userId: this.userId
                })
            }
        }
    },
    components: {
        ImageVant,
    }
}
</script>

<style lang="scss" scoped>
    .head-img {
        display: inline-block;
        position: relative;
        cursor: pointer;

        .user-img {
            width: 100%;
            height: 100%;
        }
    }
</style>